package com.swallow.auth.application.api.tenant;

import com.swallow.auth.api.tenant.ITenantFacade;
import com.swallow.auth.common.enums.ErrorCode;
import com.swallow.auth.common.exception.ParamException;
import com.swallow.auth.common.result.Result;
import com.swallow.auth.common.utils.GsonUtil;
import com.swallow.auth.domain.tenant.model.TenantEntity;
import com.swallow.auth.domain.tenant.model.TenantRoot;
import com.swallow.auth.domain.tenant.service.ITenantDomainService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 18310740596@163.com
 * @date: 2024-05-11 21:33:07
 * @version: v1.0
 * @describe: 租户面板
 */
@Slf4j
@RestController
public class TenantFacadeImpl implements ITenantFacade {

    @Resource private ITenantDomainService tenantDomainService;

    @Override
    public Result<String> create(String tenantName) {
        log.info("创建租户::: 请求参数:{}", tenantName);

        TenantRoot tenantRoot = new TenantRoot();
        tenantRoot.setTenantEntity(TenantEntity.builder().tenantName(tenantName).build());

        Result<String> result = tenantDomainService.createTenant(tenantRoot);
        log.info("创建租户::: 租户创建完成,响应信息:{}", GsonUtil.toJson(result));

        return result;
    }

    @Override
    public Result<Void> delete(String tenantNo) {

        return null;
    }
}
